*** Settings ***
Resource          COMM_LIST.robot

*** Keywords ***
Is Val Exist In Dict
    [Arguments]    ${dict}    ${val}
    ${values}=    Get Dictionary Values    ${dict}
    ${isExist}=    Is Exist In List    ${values}    ${val}
    [Return]    ${isExist}

Is Key Exist In Dict
    [Arguments]    ${dict}    ${key}
    ${keys}=    Get Dictionary Keys    ${dict}
    ${isExist}=    Is Exist In List    ${keys}    ${key}
    [Return]    ${isExist}

Get Value From Dict
    [Arguments]    ${dict}    ${key}
    ${isExist}=    Is Key Exist In Dict    ${dict}    ${key}
    ${values}=    Get Dictionary Values    ${dict}
    ${val}=    Set Variable if    ${isExist}==-1    None    ${isExist}!=-1    ${values}[${isExist}]
    [Return]    ${val}

Update Value From Dict
    [Arguments]    ${dict}    ${key}    ${val}
    [Documentation]    字典有数据则不更新
    ${isExist}=    Is Key Exist In Dict    ${dict}    ${key}
    run keyword if    ${isExist}==-1    Set To Dictionary    ${dict}    ${key}=${val}
    [Return]    ${dict}

Del Value From Dict
    [Arguments]    ${dict}    ${key}
    [Documentation]    字典有数据则不更新
    ${isExist}=    Is Key Exist In Dict    ${dict}    ${key}
    run keyword if    ${isExist}!=-1    Remove From Dictionary    ${dict}    ${key}
    [Return]    ${dict}
